<%@ page import="com.wuchao.service.serviceImpl.ServiceImpl" %>
<%@ page import="org.apache.ibatis.annotations.Insert" %><%--
  Created by IntelliJ IDEA.
  User: Root404
  Date: 2022/6/27
  Time: 9:43
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <%
        request.setCharacterEncoding("utf-8");
        String op = request.getParameter("op");
        if(op!=null){
            ServiceImpl service = new ServiceImpl();
            if(op.equals("delete")){//判断删除标志
                 int id= Integer.parseInt(request.getParameter("id")) ;
                int update = service.update("delete from user where id=?", id);
                if(update>0){//回去判断
                    request.getRequestDispatcher("main.jsp?isdelete1=t").forward(request,response);
                }else{
                    response.sendRedirect("main.jsp?isdelete2=t");
                }

            }else   if(op.equals("add")){//判断删除标志
                String name = request.getParameter("name");
                String sex = request.getParameter("sex");

                int update = service.update("insert user(name,sex) values(?,?)", name,sex);
                if(update>0){//回去判断
                    request.getRequestDispatcher("main.jsp?isadd1=t").forward(request,response);
                }else{
                    response.sendRedirect("main.jsp?isadd2=t");
                }

            }else {
                response.sendRedirect("main.jsp?feifa=t");
            }

        }else{//空的回去
            response.sendRedirect("main.jsp?feifa=t");
        }
    %>
</body>
</html>
